﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page 
{
    protected string Article;
    protected LocalFunctions FUNC;
    protected string sImages;
    protected DataTable DTEvents;

    protected string sKeywords, sDescription;


    protected void Page_Load(object sender, EventArgs e)
    {
        FUNC = ((Rondo)Master).FUNC;
        Calendar1.FUNC = FUNC;
        // GetData
        Dal.arParams.Clear();
        Dal.arParams.Add(1);
        Dal.arParams.Add(FUNC.LangID);
        DataTable DT = Dal.ExecuteDBsp("RD_SelectStaticPageById", Dal.arParams);
        if (DT != null)
        {
            if (DT.Rows.Count > 0)
            {
                Title = DT.Rows[0]["BrowserTitle"].ToString();
                sKeywords = DT.Rows[0]["Keywords"].ToString();
                sDescription = DT.Rows[0]["Description"].ToString();
                ContentTitle.InnerHtml = "<h2>" + DT.Rows[0]["ContentTitle"].ToString() + "</h2>";
                Article = DT.Rows[0]["PageContent"].ToString();
            }
        }

        //Get images data
        Dal.arParams.Clear();
        Dal.arParams.Add(FUNC.LangID);
        Dal.arParams.Add(1);
        Dal.arParams.Add(0);
        DataSet DSImages = Dal.ExecuteDBspDS("RD_GetGalleryByID", Dal.arParams);

        if(DSImages!=null)
            if(DSImages.Tables.Count>0)
                foreach (DataRow drImage in DSImages.Tables[1].Rows)
                {
                    sImages += string.Format("<img src=\"Gallery/{0}\" alt=\"\" />", drImage["imagepath"]);
                }


        // GetCalendarEvents
        Dal.arParams.Clear();
        Dal.arParams.Add(FUNC.LangID);
        Dal.arParams.Add(DateTime.Now.Month);
        Dal.arParams.Add(DateTime.Now.Year);
        DTEvents = Dal.ExecuteDBsp("RD_GetEventsForTop", Dal.arParams);
        dlEvents.DataSource = DTEvents;
        dlEvents.DataBind();

        if (FUNC.LangID == 2)
        {
            dlEvents.Attributes.Add("dir", "rtl");
            dlEvents.Attributes.Add("style", "float:right;");
        }
    }
}
